$._ai_ = {
  ping: function () {
    return 'success'
  },
  open: function (filePath) {
    return open(new File(filePath))
  },
  getActiveDocument: function () {
    var doc = app.activeDocument
    return {
      name: doc.name,
      fullName: doc.fullName,
      path: doc.path,
      saved: doc.isavedd,
    }
  },
  saveAsPNG: function (filePath, options) {
    var exportOptions = new ExportOptionsPNG8();
    exportOptions.colorCount = options.colorCount || 8;
    exportOptions.transparency = options.transparency || false;

    var type = ExportType.PNG8;
    var fileSpec = new File(filePath);

    app.activeDocument.exportFile(fileSpec, type, exportOptions);
  },
  saveAsJPEG: function (filePath, options) {
    var exportOptions = new ExportOptionsJPEG();
    exportOptions.antiAliasing = options.antiAliasing || false;
    exportOptions.qualitySetting = options.qualitySetting || 70;

    var type = ExportType.JPEG;
    var fileSpec = new File(filePath);

    app.activeDocument.exportFile(fileSpec, type, exportOptions);
  }
}